package com.leetcode.partition8;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/24 9:37
 */
public class LC731我的日程安排表II {

    private static SegmentTree root = new SegmentTree(0, (int) 1e9);

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int m = Integer.parseInt(reader.readLine());
        while (m-- > 0) {
            String[] ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            writer.write(book(a, b) + "\n");
            writer.flush();
        }
        writer.flush();
    }

    public static boolean book(int start, int end) {
        if (query(root, start, end - 1) >= 2) return false;
        modify(root, start, end - 1, 1);
        return true;
    }

    private static int query(SegmentTree root, int l, int r) {
        if (l <= root.l && r >= root.r) return root.max + root.lazy;
        pushdown(root);
        int mid = root.l + root.r >> 1, res = 0;
        if (l <= mid) res = query(root.left(), l, r);
        if (r > mid) res = Math.max(res, query(root.right(), l, r));
        return res;
    }

    private static void pushdown(SegmentTree root) {
        if (root.lazy != 0) {
            root.left().lazy += root.lazy;
            root.right().lazy += root.lazy;
            root.max += root.lazy;
            root.lazy = 0;
        }
    }

    private static int modify(SegmentTree root, int l, int r, int v) {
        if (l <= root.l && r >= root.r) {
            root.lazy += v;
            return root.max + root.lazy;
        }
        pushdown(root);
        int mid = root.l + root.r >> 1;
        if (l <= mid) root.max = Math.max(root.max, modify(root.left(), l, r, v));
        if (r > mid) root.max = Math.max(root.max, modify(root.right(), l, r, v));
        return root.max;
    }

    private static class SegmentTree {
        private int l, r, lazy, max;
        private SegmentTree lc, rc;

        public SegmentTree(int l, int r) {
            this.l = l;
            this.r = r;
        }

        private SegmentTree left() {
            if (lc == null) {
                int mid = l + r >> 1;
                lc = new SegmentTree(l, mid);
            }
            return lc;
        }

        private SegmentTree right() {
            if (rc == null) {
                int mid = l + r >> 1;
                rc = new SegmentTree(mid + 1, r);
            }
            return rc;
        }
    }
}
